home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 21.zip
/
BS1 part 21
/
Professional Page v4.0 (1993)(Gold Disk)(Disk 1 of 4)[HD].7z
/
Professional Page v4.0 (1993)(Gold Disk)(Disk 1 of 4)[HD].adf
/
rexx.lzh
/
FormatDate.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1992-03-13
|
3KB
|
126 lines
/*
@B@LFormatDate.rexx@b Copyright Gold Disk Inc, February 2, 1992
This Arexx macro will return a formatted date string based on input.
The macro is called in the following way:
FormatDate([day]|[month]|[daynum]|[monthnum]|[year]|[dayofmonth])
all argmuments must be a string
Example
say FormatDate("Today is %dayname, %monthname the %dayofmonth, %year")
>> Today is Monday, January the 20, 1992
say FormatDate("Time is %day @civil")
*/
parse arg inputstring, inputdate
if inputdate = '' then inputdate = date(s)
datekeywords = "%WEEKDAY %DAYS %CENTURY %BASE %MONTHNAME %FMONTH %EUROPEAN %JULIAN %ORDERED %NORMAL %STANDARD %INTERNAL %USA %YEAR %ZYEAR %TDATE"
timekeywords = "@ELAPSED @CIVIL @HOURS @MINUTES @SECONDS @NORMAL"
upperstring = upper(inputstring)
if pos('%', upperstring) ~= 0 then
do wrds = 1 to words(datekeywords)
wrd = word(datekeywords, wrds)
wlen = length(wrd)
abrv = left(wrd, 2)
wpos = 1
wpos = pos(wrd, upperstring)
do while wpos ~= 0
inputstring = delstr(inputstring, wpos, wlen)
upperstring = delstr(upperstring, wpos, wlen)
date = calcdate(wrd)
inputstring = insert(date, inputstring, wpos - 1)
upperstring = insert(date, upperstring, wpos - 1)
wpos = pos(wrd, upperstring,wpos)
end
wpos = 1
wpos = pos(abrv, upperstring)
do while wpos ~= 0
inputstring = delstr(inputstring, wpos, 2)
upperstring = delstr(upperstring, wpos, 2)
date = calcdate(abrv)
inputstring = insert(date, inputstring, wpos - 1)
upperstring = insert(date, upperstring, wpos - 1)
wpos = pos(abrv, upperstring,wpos)
end
end
if pos('@', upperstring) ~= 0 then
do wrds = 1 to words(timekeywords)
wrd = word(timekeywords, wrds)
wlen = length(wrd)
abrv = left(wrd, 2)
wpos = 1
wpos = pos(wrd, upperstring)
do while wpos ~= 0
inputstring = delstr(inputstring, wpos, wlen)
upperstring = delstr(upperstring, wpos, wlen)
date = calctime(wrd)
inputstring = insert(date, inputstring, wpos - 1)
upperstring = insert(date, upperstring, wpos - 1)
wpos = pos(wrd, upperstring,wpos)
end
wpos = 1
wpos = pos(abrv, upperstring)
do while wpos ~= 0
inputstring = delstr(inputstring, wpos, 2)
upperstring = delstr(upperstring, wpos, 2)
date = calctime(abrv)
inputstring = insert(date, inputstring, wpos - 1)
upperstring = insert(date, upperstring, wpos - 1)
wpos = pos(abrv, upperstring,wpos)
end
end
return(inputstring)
calcdate: procedure expose inputdate
do
arg input
key = substr(input, 2, 1)
if key = 'F' then
return(substr(date(u,inputdate,s), 1, 2)) * 1
else if key = 'Y' then
return(word(date(,inputdate,s), 3)) * 1
else if key = 'T' then
return(substr(date(,inputdate,s), 1, 2)) * 1
else if key = 'Z' then
return(substr(date(u,inputdate,s), 7, 2)) * 1
return(date(key,inputdate,s))
end
calctime: procedure
do
arg input
key = time(substr(input, 2, 1))
if datatype(key, n) then return(key * 1)
else return(key)
end